package service

import (
	"context"
	"mall-portalv2/internal/model"
)

func (s *Service) QueryOmsOrderItemWhereOrderId(ctx context.Context, OrderId int64) ([]model.OmsOrderItem, error) {

	var (
		result []model.OmsOrderItem
		err    error
	)

	result, err = s.dao.QueryOmsOrderItemWhereOrderId(ctx, OrderId)
	if err != nil {
		return []model.OmsOrderItem{}, err
	}
	return result, err
}

func (s *Service) QueryOmsOrderItemWhereOrderIds(ctx context.Context, Ids []int64) ([]model.OmsOrderItem, error) {

	var (
		result []model.OmsOrderItem
		err    error
	)

	result, err = s.dao.QueryOmsOrderItemWhereOrderIds(ctx, Ids)
	if err != nil {
		return []model.OmsOrderItem{}, err
	}
	return result, err
}

func (s *Service) QueryOmsItemAndProductWhereOrderId(ctx context.Context, OrderId int64) ([]model.OmsOrderItemAndProduct, error) {

	var (
		result []model.OmsOrderItemAndProduct
		err    error
	)

	result, err = s.dao.QueryOmsItemAndProductWhereOrderId(ctx, OrderId)
	if err != nil {
		return []model.OmsOrderItemAndProduct{}, err
	}
	return result, err
}

func (s *Service) CreateOrderItem(ctx context.Context, insertData model.OmsOrderItem) (model.OmsOrderItem, error) {
	result, err := s.dao.CreateOrderItem(ctx, insertData)
	if err != nil {
		return model.OmsOrderItem{}, err
	}
	return result, err
}

func (s *Service) QueryOmsOrderItemCountWhereUserIdAndProductId(ctx context.Context, PromotionSkuId int64, memberId int64) ([]model.OmsOrderItemAndOrder, error) {

	var (
		result []model.OmsOrderItemAndOrder
		err    error
	)

	result, err = s.dao.QueryOmsOrderItemCountWhereUserIdAndProductId(ctx, PromotionSkuId, memberId)
	if err != nil {
		return result, err
	}
	return result, err
}

func (s *Service) QueryOmsItemAndProductWhereOrderIds(ctx context.Context, Ids []int64) ([]model.OmsOrderItemAndProduct, error) {

	var (
		result []model.OmsOrderItemAndProduct
		err    error
	)

	result, err = s.dao.QueryOmsItemAndProductInOrderIds(ctx, Ids)
	if err != nil {
		return []model.OmsOrderItemAndProduct{}, err
	}
	return result, err
}
